package org.jeecg.modules.business.doc.business.controller;

import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.PageUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.transtella.messageCenter.IMessageManager;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.exception.JeecgBootException;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.common.util.BeanUtil;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.basic.material.entity.BasicMaterial;
import org.jeecg.modules.basic.material.mapper.BasicMaterialMapper;
import org.jeecg.modules.basic.unit.service.IBasicUnitService;
import org.jeecg.modules.basic.warehouse.entity.WmsBasicWarehouseAreaLocation;
import org.jeecg.modules.business.doc.business.entity.WmsInReceipt;
import org.jeecg.modules.business.doc.business.entity.WmsInReceiptMaterial;
import org.jeecg.modules.business.doc.business.entity.dto.ListByWarehouseIdResponseVO;
import org.jeecg.modules.business.doc.business.entity.vo.WmsInReceiptQueryVO;
import org.jeecg.modules.business.doc.business.service.IWmsInReceiptMaterialService;
import org.jeecg.modules.business.doc.business.service.IWmsInReceiptService;
import org.jeecg.modules.business.doc.business.vo.*;
import org.jeecg.modules.business.doc.outbound.entity.WmsOutReceiptMaterial;
import org.jeecg.modules.business.doc.outbound.entity.vo.UnCreateInVO;
import org.jeecg.modules.business.doc.outbound.entity.vo.UnCreateReqVO;
import org.jeecg.modules.business.warehouse.entity.WmsInReceiptTask;
import org.jeecg.modules.business.warehouse.entity.WmsInReceiptTaskMaterial;
import org.jeecg.modules.business.warehouse.mapper.WmsInReceiptTaskMapper;
import org.jeecg.modules.business.warehouse.mapper.WmsInReceiptTaskMaterialMapper;
import org.jeecg.modules.flow.callback.enums.TransferStatusEnum;
import org.jeecg.modules.utils.entity.WmsBaseDocument;
import org.jeecg.modules.utils.service.IWmsBaseDocumentService;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.util.*;
import java.util.stream.Collectors;


/**
 * @Description: 入库单
 * @Author: jeecg-boot
 * @Date: 2023-07-31
 * @Version: V1.0
 */
@Api(tags = "入库单")
@RestController
@RequestMapping("/business/wmsInReceipt")
@Slf4j
public class WmsInReceiptController {
    @Autowired
    private IWmsInReceiptService wmsInReceiptService;
    @Autowired
    private IWmsInReceiptMaterialService wmsInReceiptMaterialService;
    @Resource
    private BasicMaterialMapper basicMaterialMapper;
    @Autowired
    private IWmsBaseDocumentService wmsBaseDocumentService;
    @Autowired
    private IMessageManager messageManager;
    @Resource
    private WmsInReceiptTaskMapper wmsInReceiptTaskMapper;
    @Resource
    private WmsInReceiptTaskMaterialMapper wmsInReceiptTaskMaterialMapper;
    @Autowired
    private IBasicUnitService iBasicUnitService;

    private static final String CLOSE = "-1";

    /**
     * 入库单提交
     *
     * @param id
     * @return
     */
    @ApiOperation(value = "入库单提交", notes = "入库单提交")
    @GetMapping("/commit")
    public Result commit(@RequestParam("id") String id,
                         HttpServletRequest req) {
        WmsInReceipt byId = wmsInReceiptService.getById(id);
        String wmsInReceiptTaskId = byId.getWmsInReceiptTaskId();
        WmsInReceiptTask task = wmsInReceiptTaskMapper.selectById(wmsInReceiptTaskId);
        if (task.getDocumentStatus().equals(CLOSE)) {
            throw new JeecgBootException("当前订单绑定的入库任务已关闭，无法提交");
        }
        WmsBaseDocument document = wmsBaseDocumentService.getById(id);
        if (document == null) {
            return Result.error("未能确定单据类型!");
        }
        int committedRows = wmsBaseDocumentService.updateDocumentToCommitted(document.getId(), document.getTableName());
        if (committedRows != 1) {
            return Result.OK().error500("提交失败,只能提交已保存状态的数据");
        }
        messageManager.sendCommand(req.getHeader(CommonConstant.X_ACCESS_TOKEN),
                "commit." + document.getTableName(), document.getId());
        return Result.ok();
    }

    /**
     * 通过入库任务id查询入库任务物料对应入库单物料相同字段
     *
     * @param id
     * @return
     */
    @ApiOperation(value = "通过入库任务id查询入库任务物料对应入库单物料相同字段", notes = "通过入库任务id查询入库任务物料对应入库单物料相同字段")
    @GetMapping("/listByWarehouseTaskId")
    public Result<List<ListByWarehouseIdResponseVO>> listByWarehouseTaskId(@RequestParam("id") String id) {
        List<ListByWarehouseIdResponseVO> wmsInReceiptMaterials = wmsInReceiptService.listByWarehouseTaskId(id);
        return Result.OK(wmsInReceiptMaterials);
    }

    /**
     * 分页列表查询
     *
     * @param wmsInReceipt
     * @param pageNo
     * @param pageSize
     * @param req
     * @return
     */
    //@AutoLog(value = "入库单-分页列表查询")
    @ApiOperation(value = "入库单-分页列表查询", notes = "入库单-分页列表查询")
    @GetMapping(value = "/list")
    public Result<IPage<WmsInReceipt>> queryPageList(WmsInReceiptQueryVO wmsInReceipt,
                                                     @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                     @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                                     HttpServletRequest req) {
        Page<WmsInReceipt> page = new Page<WmsInReceipt>(pageNo, pageSize);
        IPage<WmsInReceipt> pageList = wmsInReceiptService.listByPage(page, wmsInReceipt);
        List<WmsInReceipt> records = pageList.getRecords();
        List<String> collect = records
                .stream()
                .map(r -> r.getId()).collect(Collectors.toList());
        List<WmsInReceiptMaterial> materials = wmsInReceiptMaterialService.list(new LambdaQueryWrapper<WmsInReceiptMaterial>()
                .in(CollectionUtil.isNotEmpty(collect), WmsInReceiptMaterial::getWmsInReceiptId, collect));
        records.stream().forEach(record -> {
            if (materials.stream().filter(m -> m.getWmsInReceiptId().equals(record.getId())).count() > 0) {
                record.setHasChild(1);
            } else {
                record.setHasChild(0);
            }
            // 根据单据任务id查询任务编号
            WmsInReceiptTask wmsInReceiptTask = wmsInReceiptTaskMapper.selectOne(new LambdaQueryWrapper<WmsInReceiptTask>()
                    .eq(WmsInReceiptTask::getId, record.getWmsInReceiptTaskId()));
            if (ObjectUtil.isNotNull(wmsInReceiptTask)) {
                record.setUpstreamNumber(wmsInReceiptTask.getDocumentCode());
            }
            if (Objects.equals(TransferStatusEnum.TRANSFER_FAIL.getCode(),record.getTransferSapStatus())){
                record.setTransferButton(true);
            }else {
                record.setTransferButton(false);
            }
        });
        pageList.setRecords(records);
        return Result.OK(pageList);
    }

    /**
     * 添加
     *
     * @param wmsInReceiptPage
     * @return
     */
    @AutoLog(value = "入库单-添加")
    @ApiOperation(value = "入库单-添加", notes = "入库单-添加")
    @RequiresPermissions("business:wms_in_receipt:add")
    @PostMapping(value = "/add")
    public Result<String> add(@RequestBody WmsInReceiptPage wmsInReceiptPage) {
        WmsInReceipt wmsInReceipt = new WmsInReceipt();
        BeanUtils.copyProperties(wmsInReceiptPage, wmsInReceipt);
        String s = wmsInReceiptService.saveMain(wmsInReceipt, wmsInReceiptPage.getWmsInReceiptMaterialList());
        return Result.OK("新增成功!", s);
    }

    /**
     * 编辑
     *
     * @param wmsInReceiptPage
     * @return
     */
    @AutoLog(value = "入库单-编辑")
    @ApiOperation(value = "入库单-编辑", notes = "入库单-编辑")
    @RequiresPermissions("business:wms_in_receipt:edit")
    @RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
    public Result<String> edit(@RequestBody WmsInReceiptPage wmsInReceiptPage) {
        WmsInReceipt wmsInReceipt = new WmsInReceipt();
        BeanUtils.copyProperties(wmsInReceiptPage, wmsInReceipt);
        WmsInReceipt wmsInReceiptEntity = wmsInReceiptService.getById(wmsInReceipt.getId());
        if (wmsInReceiptEntity == null) {
            return Result.error("未找到对应数据");
        }
        wmsInReceiptService.updateMain(wmsInReceipt, wmsInReceiptPage.getWmsInReceiptMaterialList());
        return Result.OK("编辑成功!");
    }

    /**
     * 通过id删除
     *
     * @param id
     * @return
     */
    @AutoLog(value = "入库单-通过id删除")
    @ApiOperation(value = "入库单-通过id删除", notes = "入库单-通过id删除")
    @RequiresPermissions("business:wms_in_receipt:delete")
    @DeleteMapping(value = "/delete")
    public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
        wmsInReceiptService.delMain(id);
        return Result.OK("删除成功!");
    }

    /**
     * 批量删除
     *
     * @param ids
     * @return
     */
    @AutoLog(value = "入库单-批量删除")
    @ApiOperation(value = "入库单-批量删除", notes = "入库单-批量删除")
    @RequiresPermissions("business:wms_in_receipt:deleteBatch")
    @DeleteMapping(value = "/deleteBatch")
    public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
        this.wmsInReceiptService.delBatchMain(Arrays.asList(ids.split(",")));
        return Result.OK("批量删除成功！");
    }

    /**
     * 通过入库单id查询入库单
     *
     * @param id
     * @return
     */
    //@AutoLog(value = "入库单-通过id查询")
    @ApiOperation(value = "入库单-通过id查询", notes = "入库单-通过id查询")
    @GetMapping(value = "/queryById")
    public Result<WmsInReceipt> queryById(@RequestParam(name = "id", required = true) String id) {
        WmsInReceipt wmsInReceipt = wmsInReceiptService.getById(id);
        if (wmsInReceipt == null) {
            return Result.error("未找到对应数据");
        }
        return Result.OK(wmsInReceipt);

    }

    /**
     * 通过入库单id查询子表
     *
     * @param
     * @return
     */
    //@AutoLog(value = "入库单-物料通过主表ID查询")
    @ApiOperation(value = "通过入库单id查询子表", notes = "通过入库单id查询子表")
    @GetMapping(value = "/queryWmsInReceiptMaterialByMainId")
    public Result<List<WmsInReceiptMaterialResponseVO>> queryWmsInReceiptMaterialListByMainId(@RequestParam(name = "id", required = true) String id) {
        //获取对应入库任务表体的计划数量、已入库数量、未入库数量
        Map<String, WmsInReceiptTaskMaterial> map = new HashMap<>();
        WmsInReceipt inReceipt = wmsInReceiptService.getById(id);
        List<WmsInReceiptTaskMaterial> taskMaterials = wmsInReceiptTaskMaterialMapper.selectList(new LambdaQueryWrapper<WmsInReceiptTaskMaterial>()
                .eq(WmsInReceiptTaskMaterial::getWmsInReceiptTaskId, inReceipt.getWmsInReceiptTaskId())
        );
        if (CollectionUtil.isNotEmpty(taskMaterials)){
            map = taskMaterials.stream().collect(Collectors.toMap(WmsInReceiptTaskMaterial::getId, s -> s));
        }
        List<WmsInReceiptMaterial> wmsInReceiptMaterialList = wmsInReceiptMaterialService.selectByMainId(id);
        List<WmsInReceiptMaterialResponseVO> list = BeanUtil.copyToList(wmsInReceiptMaterialList, WmsInReceiptMaterialResponseVO.class);
        for (WmsInReceiptMaterialResponseVO vo : list) {
            BasicMaterial basicMaterial = basicMaterialMapper.selectOne(new LambdaQueryWrapper<BasicMaterial>()
                    .eq(BasicMaterial::getId, vo.getWmsBasicMaterialId()));
            if (ObjectUtil.isNotEmpty(basicMaterial)) {
                vo.setMaterialName(basicMaterial.getName());
                vo.setMaterialCode(basicMaterial.getCode());
                vo.setSpecification(basicMaterial.getSpecification());
                vo.setUnitAssistId(basicMaterial.getAssistantUnitId());
//                vo.setWmsBasicUnitId(basicMaterial.getInventoryUnitId());
            }
            if (StrUtil.isNotEmpty(vo.getIsMergeRoll())){
                if ("Y".equals(vo.getIsMergeRoll())){
                    vo.setIsMergeRoll("1");
                }
                if ("N".equals(vo.getIsMergeRoll())){
                    vo.setIsMergeRoll("0");
                }
            }
            WmsInReceiptTaskMaterial taskMaterial = map.get(vo.getWmsInReceiptTaskMaterialId());
            if (taskMaterial != null){
                vo.setPlanQuantity(taskMaterial.getPlanQuantity());
                vo.setWarehousedQuantity(taskMaterial.getWarehousedQuantity());
                vo.setUnwarehousedQuantity(taskMaterial.getUnwarehousedQuantity());
                vo.setWmsBasicWarehouseSuggestId(taskMaterial.getWmsBasicWarehouseId());
                vo.setWmsBasicWarehouseAreaSuggestId(taskMaterial.getWmsBasicWarehouseAreaId());
                vo.setWmsBasicWarehouseAreaLocationSuggestId(taskMaterial.getWmsBasicWarehouseAreaLocationId());
            }
        }
        return Result.OK(list);
    }
    /**
     * 通过入库单id查询子表
     *
     * @param
     * @return
     */
    //@AutoLog(value = "入库单-物料通过主表ID查询")
    @ApiOperation(value = "通过入库单id查询子表", notes = "通过入库单id查询子表")
    @GetMapping(value = "/queryWmsInReceiptMaterialByMainIdPage")
    public Result<IPage<WmsInReceiptMaterialResponseVO>> queryWmsInReceiptMaterialListByMainIdPage(@RequestParam(name = "id", required = true) String id,
                                                                                                   @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
        //获取对应入库任务表体的计划数量、已入库数量、未入库数量
        Map<String, WmsInReceiptTaskMaterial> map = new HashMap<>();
        WmsInReceipt inReceipt = wmsInReceiptService.getById(id);
        List<WmsInReceiptTaskMaterial> taskMaterials = wmsInReceiptTaskMaterialMapper.selectList(new LambdaQueryWrapper<WmsInReceiptTaskMaterial>()
                .eq(WmsInReceiptTaskMaterial::getWmsInReceiptTaskId, inReceipt.getWmsInReceiptTaskId())
        );
        if (CollectionUtil.isNotEmpty(taskMaterials)){
            map = taskMaterials.stream().collect(Collectors.toMap(WmsInReceiptTaskMaterial::getId, s -> s));
        }

        List<WmsInReceiptMaterial> wmsInReceiptMaterialList = wmsInReceiptMaterialService.selectByMainId(id);
        List<WmsInReceiptMaterialResponseVO> list = BeanUtil.copyToList(wmsInReceiptMaterialList, WmsInReceiptMaterialResponseVO.class);
        for (WmsInReceiptMaterialResponseVO vo : list) {
            BasicMaterial basicMaterial = basicMaterialMapper.selectOne(new LambdaQueryWrapper<BasicMaterial>()
                    .eq(BasicMaterial::getId, vo.getWmsBasicMaterialId()));
            if (ObjectUtil.isNotEmpty(basicMaterial)) {
                vo.setMaterialName(basicMaterial.getName());
                vo.setMaterialCode(basicMaterial.getCode());
                vo.setSpecification(basicMaterial.getSpecification());
                vo.setUnitAssistId(basicMaterial.getAssistantUnitId());
//                vo.setWmsBasicUnitId(basicMaterial.getInventoryUnitId());
            }
            if (StrUtil.isNotEmpty(vo.getIsMergeRoll())){
                if ("Y".equals(vo.getIsMergeRoll())){
                    vo.setIsMergeRoll("1");
                }
                if ("N".equals(vo.getIsMergeRoll())){
                    vo.setIsMergeRoll("0");
                }
            }
            WmsInReceiptTaskMaterial taskMaterial = map.get(vo.getWmsInReceiptTaskMaterialId());
            if (taskMaterial != null){
                vo.setPlanQuantity(taskMaterial.getPlanQuantity());
                vo.setWarehousedQuantity(taskMaterial.getWarehousedQuantity());
                vo.setUnwarehousedQuantity(taskMaterial.getUnwarehousedQuantity());
            }
        }
        IPage<WmsInReceiptMaterialResponseVO> res = new Page<>();
        List<WmsInReceiptMaterialResponseVO> pageList = new ArrayList<>();
        try {
            pageList = ListUtil.page(pageNo - 1, pageSize, list);
        }catch (Exception e){
            //前端未做页数限制,传的pageNo大于返回的pages时会报错
        }
        res.setRecords(pageList);
        res.setTotal(list.size());
        res.setPages(PageUtil.totalPage(list.size(),pageSize));
        res.setSize(pageSize);
        res.setCurrent(pageNo);
        return Result.OK(res);
    }
    /**
     * 通过入库任务查询入库单
     *
     * @param id
     * @return
     */
    @ApiOperation(value = "入库单-通过任务id查询", notes = "入库单-通过任务id查询")
    @GetMapping(value = "/queryByTaskId")
    public Result<List<WmsInReceipt>> queryByTaskId(@RequestParam(name = "id", required = true) String id) {
        WmsInReceiptTask wmsInReceiptTask = wmsInReceiptTaskMapper.selectById(id);
        List<WmsInReceipt> list = wmsInReceiptService.list(new LambdaQueryWrapper<WmsInReceipt>()
                .eq(WmsInReceipt::getWmsInReceiptTaskId,wmsInReceiptTask.getId())
        );
        return Result.OK(list);
    }

    /**
     * 导出excel
     *
     * @param request
     * @param wmsInReceipt
     */
    @ApiOperation(value = "导出excel")
    @RequiresPermissions("business:wms_in_receipt:exportXls")
    @RequestMapping(value = "/exportXls", method = RequestMethod.POST)
    public ModelAndView exportXls(HttpServletRequest request, WmsInReceipt wmsInReceipt) {
        // Step.1 组装查询条件查询数据
        QueryWrapper<WmsInReceipt> queryWrapper = QueryGenerator.initQueryWrapper(wmsInReceipt, request.getParameterMap());
        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();

        //配置选中数据查询条件
        String selections = request.getParameter("selections");
        if (oConvertUtils.isNotEmpty(selections)) {
            List<String> selectionList = Arrays.asList(selections.split(","));
            queryWrapper.in("id", selectionList);
        }
        //Step.2 获取导出数据
        List<WmsInReceipt> wmsInReceiptList = wmsInReceiptService.list(queryWrapper);
        List<String> receiptIds = wmsInReceiptList.stream().map(w -> w.getId()).collect(Collectors.toList());
        List<WmsInReceiptMaterial> receiptMaterials = wmsInReceiptMaterialService.list(new LambdaQueryWrapper<WmsInReceiptMaterial>()
                .in(WmsInReceiptMaterial::getWmsInReceiptId, receiptIds));
        Map<String, List<WmsInReceiptMaterial>> listMap = new HashMap<>();
        if(receiptMaterials != null){
            listMap = receiptMaterials.stream().collect(Collectors.groupingBy(WmsInReceiptMaterial::getWmsInReceiptId));
        }

        // Step.3 组装pageList
        List<WmsInReceiptPage> pageList = new ArrayList<WmsInReceiptPage>();
        for (WmsInReceipt main : wmsInReceiptList) {
            WmsInReceiptPage vo = new WmsInReceiptPage();
            BeanUtils.copyProperties(main, vo);
            List<WmsInReceiptMaterial> wmsInReceiptMaterialList = listMap.getOrDefault(main.getId(),new ArrayList<>());
            vo.setWmsInReceiptMaterialList(wmsInReceiptMaterialList);
            pageList.add(vo);
        }

        // Step.4 AutoPoi 导出Excel
        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
        mv.addObject(NormalExcelConstants.FILE_NAME, "入库单列表");
        mv.addObject(NormalExcelConstants.CLASS, WmsInReceiptPage.class);
        mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("入库单数据", "导出人:" + sysUser.getRealname(), "入库单"));
        mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
        return mv;
    }

    /**
     * 通过excel导入数据
     *
     * @param request
     * @param response
     * @return
     */
    @ApiOperation(value = "通过excel导入数据")
    @RequiresPermissions("business:wms_in_receipt:importExcel")
    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
        MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
        Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
        for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
            // 获取上传文件对象
            MultipartFile file = entity.getValue();
            ImportParams params = new ImportParams();
            params.setTitleRows(2);
            params.setHeadRows(1);
            params.setNeedSave(true);
            try {
                List<WmsInReceiptPage> list = ExcelImportUtil.importExcel(file.getInputStream(), WmsInReceiptPage.class, params);
                for (WmsInReceiptPage page : list) {
                    WmsInReceipt po = new WmsInReceipt();
                    BeanUtils.copyProperties(page, po);
                    wmsInReceiptService.saveMain(po, page.getWmsInReceiptMaterialList());
                }
                return Result.OK("文件导入成功！数据行数:" + list.size());
            } catch (Exception e) {
                log.error(e.getMessage(), e);
                return Result.error("文件导入失败:" + e.getMessage());
            } finally {
                try {
                    file.getInputStream().close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
        return Result.OK("文件导入失败！");
    }

    /**
     * 入库策略-场景一
     *
     * @param
     * @return
     */
    @ApiOperation(value = "入库策略-场景一", notes = "入库策略-场景一")
    @GetMapping(value = "/warehousingStrategyOne")
    public Result<WarehousingStrategyOneVO> warehousingStrategyOne(WarehousingStrategyOneParamVO param) {
        return Result.OK(wmsInReceiptService.warehousingStrategyOne(param));
    }

    /**
     * 入库策略-场景二
     *
     * @param
     * @return
     */
    @ApiOperation(value = "入库策略-场景二", notes = "入库策略-场景二")
    @GetMapping(value = "/warehousingStrategy")
    public Result<WmsBasicWarehouseAreaLocation> warehousingStrategy(WarehousingStrategyParamVO param) {
        return Result.OK(wmsInReceiptService.warehousingStrategy(param));
    }

    /**
     * 选单-查询所有未创建入库单的物料信息
     * @return
     */
    @ApiOperation(value = "选单-查询所有未创建入库单的物料信息", notes = "选单-查询所有未创建入库单的物料信息")
    @PostMapping(value = "/listAllUnCreate")
    public Result<List<UnCreateInVO>> listAllUnCreate(@Valid @RequestBody UnCreateReqVO unCreateReqVO){
        List<UnCreateInVO> list=wmsInReceiptService.listAllUnCreate(unCreateReqVO);
        return Result.OK(list);
    }

    /**
     * 选单-查询入库单需要的物料信息
     * @param materialIdList
     * @return
     */
    @ApiOperation(value = "选单-查询入库单需要的物料信息", notes = "选单-查询入库单需要的物料信息")
    @PostMapping(value = "/getUnCreateMaterials")
    public Result<List<WmsInReceiptMaterialResponseVO>> getUnCreateMaterials(@RequestBody List<String> materialIdList){
        List<WmsInReceiptMaterialResponseVO> list=wmsInReceiptService.getUnCreateMaterials(materialIdList);
        return Result.ok(list);
    }
    /**
     * 入库单-过账
     * @param
     * @return
     */
    @ApiOperation(value = "入库单-过账", notes = "入库单-过账")
    @GetMapping(value = "/inReceiptTransfer")
    public Result<Void> inReceiptTransfer(@RequestParam("id")String id){
        return wmsInReceiptService.inReceiptTransfer(id);
    }

    /**
     * 盘盈单-过账
     * @param
     * @return
     */
    @ApiOperation(value = "盘盈单-过账", notes = "盘盈单-过账")
    @GetMapping(value = "/pydPassSAP")
    public Result<Void> pydPassSAP(@RequestParam("id")String id) {
        return wmsInReceiptService.pydPassSAP(id);
    }
}
